package com.books.im.handler;

import com.books.im.handler.impl.ChatMsgHandler;
import com.books.im.handler.impl.PingMsgHandler;
import com.books.model.entity.lang.Consts;
import lombok.extern.slf4j.Slf4j;

import java.util.HashMap;
import java.util.Map;

@Slf4j
public class MsgHandlerFactory {

    private static Map<String, MsgHandler> handlerMap = new HashMap<> ();

    public static void init(){
        handlerMap.put (Consts.IM_MESS_TYPE_CHAT,new ChatMsgHandler ());
        handlerMap.put (Consts.IM_MESS_TYPE_PING,new PingMsgHandler ());

        log.info ("handler factory init!!");
    }


    public static MsgHandler getMsgHandler(String type){
        return handlerMap.get (type);
    }

}
